class A_SORT{ETP, ATP< $ARR{ETP}} |
---|
**** | Algorithm class with various sorting routines. This class is a stateless collection of functions and may be used without instantiation. Sather has no way of distinguishing such modules currently
_ Usage: __a_sorter:_A_SORT{FLT,ARRAY{FLT}}; __a:_ARRAY{FLT}_:=_|1.0,2.0,3.0,1.0|; __a_sorter.sort(a); __is_sorted:_BOOL_:=_A_SORT{FLT,ARRAY{FLT}}::is_sorted(a); _ __Define_your_own_comparison_function_using_a_bound_routine: _____comp(f1,f2:_FLT):_BOOL_is _______if_f1_<_f2_then_return_true_else_return_false_end; _____end; __b:_ARRAY{FLT}_:=_|1.0,3.0,2.0|; __comp_fn:_ROUT{FLT,FLT}:BOOL_:=_bind(comp(_,_)); __a_sorter.quicksort_by(b,comp_fn,0,b.size-1); _ |
COMPARE{_} |
count_unique(a: ATP): INT |
---|
**** | Return the number of unique elements. Assume that self is sorted |
insertion_sort(a: ATP) |
---|
insertion_sort(a:ATP, order: ARRAY{INT},l,u: INT) |
---|
**** | Indirect insertion sort. As a result of sorting "l" to "u", "order" will be rearranged to contain the indicies of the elements of self in sorted order |
insertion_sort(a:ATP, l,u:INT) |
---|
**** | Stably sort the elements of self between `l' and `u' inclusive by insertion sort. `elt_lt' defines the ordering. |
insertion_sort_by(a:ATP, lt: ROUT{ETP,ETP}:BOOL, order:ARRAY{INT},l,u: INT) |
---|
**** | Indirect insertion sort. As a result of sorting "l" to "u", "order" will be rearranged to contain the indicies of the elements of self in sorted order |
insertion_sort_by(a:ATP, lt:ROUT{ETP,ETP}:BOOL,l,u: INT) |
---|
**** | Stably sort the elements of self using `t' to define "less than". Self may be void. |
is_sorted(a: ATP):BOOL |
---|
**** | True if the elements of self are in sorted order according to `elt_lt'. Self may be void. |
is_sorted(a: ATP,order: ARRAY{INT},l,u: INT): BOOL |
---|
**** | Returns true if self is sorted using the indirect array "order" between indices "l" and "u" |
is_sorted(a: ATP,l,u: INT):BOOL |
---|
**** | True if the elements of self are in sorted order according to `elt_lt'. Self may be void. |
is_sorted_by(a: ATP,lt: ROUT{ETP,ETP}:BOOL): BOOL |
---|
is_sorted_by(a: ATP,lt: ROUT{ETP,ETP}:BOOL,order: ARRAY{INT},l,u:INT): BOOL |
---|
**** | Returns true if self is sorted using the indirect array "order" between indices "l" and "u", by comparison criterion "lt" |
is_sorted_by(a: ATP,lt: ROUT{ETP,ETP}:BOOL,l,u: INT): BOOL |
---|
**** | Returns true if self is sorted using the comparison criterion "lt" |
merge_sort(into: ATP, a1,a2: ATP) |
---|
**** | Merge a1 and a2 into the destination array "into" |
merge_sort_by(into: ATP, a1,a2: ATP,lt: ROUT{ETP,ETP}:BOOL) |
---|
quicksort(a: ATP,l,u:INT) |
---|
**** | Use quicksort to sort the elements of self from `l' to `u' inclusive according to `elt_lt'. |
quicksort_by(a: ATP, lt: ROUT{ETP,ETP}:BOOL, l,u:INT) |
---|
**** | Quick |
sort(a: ATP) |
---|
**** | Default sorting uses quicksort and sorts the whole array |
sort_by(a: ATP,lt: ROUT{ETP,ETP}:BOOL) |
---|
**** | Sort the whole array "a" using the comparison function "lt" |
sort_range(a: ATP,l,u: INT) |
---|
**** | Sort the range of array elements in the index range from "l" to "u" |
check_range(a: ATP,l,u: INT): BOOL |
---|
const quicksort_limit:INT:=10; |
---|
**** | When to stop the quicksort recursion and switch to insertion sort. |
swap(a: ATP,order: ARRAY{INT},i,j: INT) |
---|
swap(a: ATP,i,j: INT) |
---|